Skip to content

Handled CollectReport without duration attribute in terminal report #13573

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

coder-aditi
Copy link
Contributor

Fix #13478

This PR adds a regression test to fix a bug in console_output_style=times that, because it lacks the duration attribute, caused a crash when a CollectReport object (from a skipped test) was included. The test helps stop future regressions and verifies that the problem no longer exists.

print(result.stderr.str())

combined = result.stdout.lines + result.stderr.lines
assert any(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I follow, doesn't the change in terminal.py prevents this message from appearing in the command line?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this fix mainly prevents the AttributeError from showing up, which is expected now asthe bug is resolved.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But the fact that the bug is fixed, means that the message does not show up, correct? any is testing that it should show up, which is wrong.

from _pytest.pytester import Pytester


def test_console_output_style_times_with_skipped_and_passed(pytester: Pytester) -> None:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason why this test is not added to test_terminal.py?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @nicoddemus , test_terminal.py was already existing,, so thought of making another new unit test file. Shall I add this in that existing file only? please let me know

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes please. 👍

@coder-aditi
Copy link
Contributor Author

Hi @nicoddemus , I made the necessary changes, please review and let me know. Thank you.

@psf-chronographer psf-chronographer bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Jun 29, 2025
Copy link
Member

@nicoddemus nicoddemus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@nicoddemus nicoddemus added the backport 8.4.x apply to PRs at any point; backports the changes to the 8.4.x branch label Jun 30, 2025
@nicoddemus nicoddemus merged commit c5a75f2 into pytest-dev:main Jul 1, 2025
36 checks passed
Copy link

patchback bot commented Jul 1, 2025

Backport to 8.4.x: 💚 backport PR created

✅ Backport PR branch: patchback/backports/8.4.x/c5a75f2498c86850c4ce13bcf10d56efc92394a4/pr-13573

Backported as #13579

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

patchback bot pushed a commit that referenced this pull request Jul 1, 2025
Fixes #13478

---------

Co-authored-by: AD <[email protected]>
Co-authored-by: Bruno Oliveira <[email protected]>
(cherry picked from commit c5a75f2)
nicoddemus added a commit that referenced this pull request Jul 1, 2025
Fixes #13478

---------

(cherry picked from commit c5a75f2)

Co-authored-by: Aditi De <[email protected]>
Co-authored-by: AD <[email protected]>
Co-authored-by: Bruno Oliveira <[email protected]>
pull bot pushed a commit to mergify-ci-insights/pytest that referenced this pull request Jul 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 8.4.x apply to PRs at any point; backports the changes to the 8.4.x branch bot:chronographer:provided (automation) changelog entry is part of PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Crash with console_output_style=times and skipping tests
3 participants